<?php
$this->pageTitle=$item->product->name.' | '.Yii::app()->name;
?>

<div class="product-page">

	<div class="float-container">

		<h1 class="name"><?php echo $item->product->name; ?></h1>

		<div class="left-column float-left text-center">
			<?php $item->product->renderImage(IMAGE_VERSION_LARGE); ?>
		</div>

		<div class="right-column float-right float-container">

			<div class="float-container">

				<div class="reservation-link float-left">
					<?php if($item->getRemainingQuantity()>0): ?>
						<p><?php echo CHtml::link(Yii::t('app','Create Reservation &raquo;'),array('//item/view','id'=>$item->id,'#'=>'create-reservation')); ?></p>
					<?php else: ?>
						<p class="bold"><?php echo Yii::t('app','This item is reserved'); ?>!</p>
					<?php endif; ?>
				</div>

				<div class="back float-right">
					<p><?php echo CHtml::link(Yii::t('app','Back to the list &raquo;'),array('//item/catalog')); ?></p>
				</div>

			</div>

			<p class="details"><?php echo str_replace(PHP_EOL,'<br />',$item->product->details); ?></p>

			<hr />

			<p class="price">
				<strong><?php echo CHtml::encode($item->product->getAttributeLabel('price')); ?></strong>:
				<?php echo Yii::app()->numberFormatter->formatCurrency($item->product->price,'EUR'); ?>
			</p>

			<p class="reserved">
				<strong><?php echo Yii::t('app','Reserved'); ?></strong>:
				<?php echo CHtml::encode($item->reservedCount); ?> / <?php echo CHtml::encode($item->quantity); ?>
			</p>

		</div>

	</div>

	<?php if($item->getRemainingQuantity()>0): ?>

		<a name="create-reservation"></a>

		<div class="create-reservation text-center">

			<h2><?php echo Yii::t('app','Create Reservation'); ?></h2>

			<?php if($item->getRemainingQuantity()>1): ?>

				<div class="form">

				<p class="tip"><?php echo Yii::t('app','If you wish to reserve one more multiple items enter the quantity and click "Create reservation"'); ?>.</p>

				<?php $form=$this->beginWidget('CActiveForm',array(
					'action'=>Yii::app()->createUrl('//item/view',array('id'=>$item->id,'#'=>'create-reservation')),
				)); ?>

					<?php echo $form->hiddenField($model,'itemId'); ?>

					<div class="row">
						<?php echo $form->labelEx($model,'quantity'); ?>
						<?php echo $form->textField($model,'quantity',array('class'=>'number-field')); ?> / <?php echo CHtml::encode($item->getRemainingQuantity()); ?>
						<?php echo $form->error($model,'quantity'); ?>
					</div>

					<?php $this->widget('zii.widgets.jui.CJuiButton', array(
						'name'=>'create-reservation-button',
						'buttonType'=>'submit',
						'caption'=>Yii::t('app','Create Reservation'),
					)); ?>

				<?php $this->endWidget(); ?>

			<?php else: ?>

				<p class="tip"><?php echo Yii::t('app','If you wish to reserve this item click "Create Reservation"'); ?>.</p>

				<?php $this->widget('zii.widgets.jui.CJuiButton', array(
					'name'=>'create-reservation-button',
					'buttonType'=>'link',
					'caption'=>Yii::t('app','Create Reservation'),
					'url'=>Yii::app()->createUrl('//reservation/create',array('itemId'=>$item->id,'quantity'=>1)),
				)); ?>

			<?php endif; ?>

			</div>

		</div>

	<?php endif; ?>

</div>